<?php
/**
 * Created by PhpStorm.
 * User: Dark
 * Date: 2015/8/15
 * Time: 22:28
 */

namespace Admin\Model;
use Think\Model;

class EmployeeModel extends Model
{
    public function addNewEmployee($data)
    {
        if(!empty($data)) {
            $this->create();
            $this->add($data);
        } else {
            return '传入数据为空！';
        }
    }

    public function deleteEmployee($id)
    {
        if(!empty($id)) {
            $this->where('id='.$id)->delete();
        } else {
            return '传入数据为空！';
        }
    }

    public function isEmployee($phone)
    {
        if(!empty($phone)) {
            $result = $this->where('phoneNumber='.$phone)->select();
            $result = $result[0];
            return $result;
        } else {
            return null;
        }
    }

    public function login($data) {
        if(!empty($data)) {
            $result = $this->where('phonenumber='.$data['phoneNumber'])->where('password='.$data['password'])->select();
            if(!empty($result)) {
                return $result;
            } else {
                return null;
            }
        }
    }
}